package easy;

public class Solution_219 {

    public static boolean containsNearbyDuplicate(int[] nums, int k) {

        for (int i = 0; i < nums.length-1; i++) {
            int maxIndex = Math.min(nums.length, i+k+1);
            for (int j = i+1; j < maxIndex; j++) {
                if (nums[i]==nums[j]) {
                    return true;
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] a = {1,2,3,1,2,3};
        System.out.println(containsNearbyDuplicate(a, 3));
    }
}
